package edu.thu.studio.ormdesigner.model.orm.table;

import com.thoughtworks.xstream.annotations.XStreamAlias;
import com.thoughtworks.xstream.annotations.XStreamAsAttribute;

import edu.thu.studio.ormdesigner.model.AbstractObjectModel;

@XStreamAlias("key")
public class Key extends AbstractObjectModel {
	private static final long serialVersionUID = 6998985022414351214L;
	@XStreamAsAttribute
	private String constraint;

	@XStreamAlias("ref-columns")
	public RefColumnSet refColumns;

	public RefColumnSet getRefColumns() {
		return refColumns;
	}

	public void setRefColumns(RefColumnSet refColumns) {
		this.refColumns = refColumns;
	}

	public String getConstraint() {
		return constraint;
	}

	public void setConstraint(String constraint) {
		this.constraint = constraint;
	}

	public boolean hasColumns() {
		if (null != this.getRefColumns()
				&& this.getRefColumns().getObjectList().size() > 0) {
			return true;
		}
		return false;
	}

	public void removeAll() {
		if (this.getRefColumns().getObjectList().size() > 0)
			this.getRefColumns().getObjectList().clear();
	}

}
